<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <style>
    li {
      list-style: none;
    }
  </style>
</head>

<body>
  <div id="app">
    <input type="text" v-model="mytext">
    <!-- {{mytext}} -->
    <button @click="touch()">add</button>
    <ul v-show="list.length">
      <li v-for="(item,a) in list">{{item}} <button @click="del(a)
        ">del</button></li>
    </ul>
    <div v-show="!list.length"> 哈哈 没了吧</div>
  </div>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        list: ['111', '222', '333'],
        mytext: ""

      },
      methods: {
        touch() {
          console.log(this);
          app.list.push(app.mytext)
          app.mytext = ''

        },
        del(i) {
          app.list.splice(i, 1,)
        }
      }
    })
  </script>
</body>

</html>